<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form>
        <div>
            <label for="">姓名</label>
            <input type="text" name="username">
        </div>
        <div>
            <label for="">密码</label>
            <input type="text" name="password">
        </div>
        <div>
            <label for="">文件</label>
            <input type="file" name="file">
        </div>
        <button type="button">提交</button>
    </form>
    <script>
        const btu=document.querySelector("button")
        btu.onclick=function(){
            const formDom=document.querySelector('form')
            const formData=new FormData(formDom);
            formData.forEach((value,key)=>{
                console.log("key:",key,"value",value);
            })
        }
    </script>
</body>
</html>